python count items in list

35

>>> from collections import Counter
>>> mylist = ["Bob", "Mike", "Bob", "Mike", "Mike", "Mike", "Bob"]
>>> Counter(mylist)
Counter({'Mike': 4, 'Bob': 3})
a = ["more", 4, 6]
print(len(a))
# prints 3

Comments

Submit
0 Comments